```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java IO与NIO深度解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
        }
        .code-block {
            background-color: #2d2d2d;
            border-radius: 8px;
            position: relative;
        }
        .copy-btn {
            position: absolute;
            right: 10px;
            top: 10px;
            background: rgba(255,255,255,0.2);
            border: none;
            color: white;
            padding: 5px 10px;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.3s;
        }
        .copy-btn:hover {
            background: rgba(255,255,255,0.3);
        }
        .feature-card {
            transition: transform 0.3s, box-shadow 0.3s;
        }
        .feature-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0,0,0,0.1);
        }
        .comparison-table {
            border-collapse: separate;
            border-spacing: 0;
        }
        .comparison-table th, .comparison-table td {
            border: 1px solid #e2e8f0;
            padding: 12px 15px;
        }
        .comparison-table th {
            background-color: #f8fafc;
            font-weight: 600;
        }
        .comparison-table tr:nth-child(even) td {
            background-color: #f8fafc;
        }
        .nav-link {
            transition: all 0.3s;
        }
        .nav-link:hover {
            color: #6e8efb;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <header class="hero-gradient text-white py-20 px-4">
        <div class="container mx-auto max-w-5xl text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-6">Java IO与NIO深度解析</h1>
            <p class="text-xl md:text-2xl mb-8 max-w-3xl mx-auto">探索同步阻塞与异步非阻塞I/O的核心差异与实现原理</p>
            <div class="flex justify-center space-x-4">
                <a href="#io" class="bg-white text-indigo-600 px-6 py-3 rounded-full font-medium hover:bg-indigo-50 transition-all">IO详解</a>
                <a href="#nio" class="border-2 border-white text-white px-6 py-3 rounded-full font-medium hover:bg-white hover:text-indigo-600 transition-all">NIO详解</a>
            </div>
        </div>
    </header>

    <!-- Navigation -->
    <nav class="sticky top-0 bg-white shadow-sm z-10">
        <div class="container mx-auto max-w-6xl px-4">
            <div class="flex justify-between items-center py-4">
                <a href="#" class="text-xl font-bold text-indigo-600">Java I/O</a>
                <div class="hidden md:flex space-x-8">
                    <a href="#io" class="nav-link">IO概念</a>
                    <a href="#io-ops" class="nav-link">IO操作</a>
                    <a href="#nio" class="nav-link">NIO概念</a>
                    <a href="#nio-ops" class="nav-link">NIO操作</a>
                    <a href="#comparison" class="nav-link">对比分析</a>
                </div>
                <button class="md:hidden text-gray-600">
                    <i class="fas fa-bars text-2xl"></i>
                </button>
            </div>
        </div>
    </nav>

    <!-- Main Content -->
    <main class="container mx-auto max-w-6xl px-4 py-12">
        <!-- IO Concept Section -->
        <section id="io" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-2 h-12 bg-indigo-500 mr-4"></div>
                <h2 class="text-3xl font-bold">1. IO与NIO概念</h2>
            </div>
            
            <div class="grid md:grid-cols-3 gap-8 mb-12">
                <!-- BIO Card -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden feature-card">
                    <div class="p-6">
                        <div class="flex items-center mb-4">
                            <div class="w-10 h-10 rounded-full bg-red-100 flex items-center justify-center mr-4">
                                <i class="fas fa-pause-circle text-red-500"></i>
                            </div>
                            <h3 class="text-xl font-semibold">BIO (Blocking I/O)</h3>
                        </div>
                        <p class="text-gray-600">同步阻塞I/O模式，服务器实现模式为一个连接一个线程，即客户端有连接请求时服务器端就需要启动一个线程进行处理。</p>
                        <div class="mt-4">
                            <span class="inline-block bg-red-100 text-red-800 px-3 py-1 rounded-full text-sm font-medium">同步阻塞</span>
                        </div>
                    </div>
                </div>
                
                <!-- NIO Card -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden feature-card">
                    <div class="p-6">
                        <div class="flex items-center mb-4">
                            <div class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center mr-4">
                                <i class="fas fa-sync-alt text-blue-500"></i>
                            </div>
                            <h3 class="text-xl font-semibold">NIO (Non-blocking I/O)</h3>
                        </div>
                        <p class="text-gray-600">同步非阻塞I/O，服务器实现模式为一个请求一个线程，客户端请求注册到多路复用器，轮询到I/O请求时才启动线程处理。</p>
                        <div class="mt-4">
                            <span class="inline-block bg-blue-100 text-blue-800 px-3 py-1 rounded-full text-sm font-medium">同步非阻塞</span>
                        </div>
                    </div>
                </div>
                
                <!-- AIO Card -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden feature-card">
                    <div class="p-6">
                        <div class="flex items-center mb-4">
                            <div class="w-10 h-10 rounded-full bg-green-100 flex items-center justify-center mr-4">
                                <i class="fas fa-bolt text-green-500"></i>
                            </div>
                            <h3 class="text-xl font-semibold">AIO (Asynchronous I/O)</h3>
                        </div>
                        <p class="text-gray-600">异步非阻塞I/O模式，当有流可以读写时操作系统会通知应用程序处理数据，应用程序只需直接处理数据而不需要实际执行I/O操作。</p>
                        <div class="mt-4">
                            <span class="inline-block bg-green-100 text-green-800 px-3 py-1 rounded-full text-sm font-medium">异步非阻塞</span>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- IO Operations Section -->
        <section id="io-ops" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-2 h-12 bg-indigo-500 mr-4"></div>
                <h2 class="text-3xl font-bold">2. IO相关操作</h2>
            </div>
            
            <div class="mb-12">
                <h3 class="text-2xl font-semibold mb-6">2.1 实现文件拷贝 -- Stream</h3>
                <div class="code-block mb-8">
                    <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy mr-2"></i>复制</button>
                    <pre class="p-4 text-gray-200 overflow-x-auto"><code>public static void main(String[] args) throws Exception {
    String inFile = "C:\\Users\\DELL\\Pictures\\电商图片\\5ab47b2cN8ab58667.jpg";
    String outFile = "C:\\Users\\DELL\\Desktop\\xxxx.jpg";

    byte[] date = new byte[1024];

    FileInputStream ips = new FileInputStream(inFile);
    FileOutputStream ops = new FileOutputStream(outFile);

    int read = 0;
    while((read = ips.read(date,0,date.length))!= -1){
        System.out.println(read);
        ops.write(date,0,read);
    };
    ops.close();
    ips.close();
}</code></pre>
                </div>
            </div>
            
            <div>
                <h3 class="text-2xl font-semibold mb-6">2.2 实现Socket通讯 -- 阻塞</h3>
                
                <div class="grid md:grid-cols-2 gap-8">
                    <!-- Server Code -->
                    <div>
                        <h4 class="text-xl font-medium mb-4 flex items-center">
                            <i class="fas fa-server text-purple-500 mr-2"></i> 服务端代码
                        </h4>
                        <div class="code-block">
                            <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy mr-2"></i>复制</button>
                            <pre class="p-4 text-gray-200 overflow-x-auto"><code>static ExecutorService executorService = Executors.newFixedThreadPool(2);
public static void main(String[] args) throws Exception {
    List&lt;Socket&gt; sockets = new ArrayList&lt;&gt;();
    ServerSocket serverSocket = new ServerSocket(88);
    
    int i = 0;
    while (true) {
        //接收客户端传过来的数据，会阻塞
        Socket accept = serverSocket.accept();
        i++;
        System.out.println("第" + i + "个客户端连接成功");
        sockets.add(accept);
        
        executorService.submit(new Runnable() {
            @Override
            public void run() {
                while(true){
                    OutputStream outputStream = null;
                    try {
                        outputStream = accept.getOutputStream();
                        InputStream inputStream = accept.getInputStream();
                        
                        byte[] data = new byte[1024];
                        int read = inputStream.read(data, 0, data.length);
                        
                        String str = new String(data, 0, read);
                        StringBuffer buffer = new StringBuffer();
                        System.out.println("服务端:" + str);
                        buffer.append(str);
                        
                        outputStream.write((buffer.toString()+"_服务端").getBytes("utf-8"));
                        outputStream.flush();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
    }
}</code></pre>
                        </div>
                    </div>
                    
                    <!-- Client Code -->
                    <div>
                        <h4 class="text-xl font-medium mb-4 flex items-center">
                            <i class="fas fa-laptop-code text-blue-500 mr-2"></i> 客户端代码
                        </h4>
                        <div class="code-block">
                            <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy mr-2"></i>复制</button>
                            <pre class="p-4 text-gray-200 overflow-x-auto"><code>public static void main(String[] args) throws Exception {
    Socket socket = new Socket("localhost", 88);
    while (true) {
        Scanner scanner = new Scanner(System.in);
        String content = scanner.nextLine();
        OutputStream outputStream = socket.getOutputStream();
        outputStream.write(content.getBytes("utf-8"));
        outputStream.flush();
        
        InputStream inputStream = null;
        try {
            inputStream = socket.getInputStream();
            byte[] data = new byte[1024];
            int read = inputStream.read(data, 0, data.length);
            System.out.println(new String(data, 0, read));
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("-----");
    }
}</code></pre>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- NIO Section -->
        <section id="nio" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-2 h-12 bg-indigo-500 mr-4"></div>
                <h2 class="text-3xl font-bold">3. NIO相关操作</h2>
            </div>
            
            <div class="mb-8">
                <h3 class="text-2xl font-semibold mb-4">NIO核心组件</h3>
                <div class="grid md:grid-cols-3 gap-6 mb-8">
                    <!-- Buffer Card -->
                    <div class="bg-white p-6 rounded-lg shadow-md">
                        <div class="flex items-center mb-4">
                            <div class="w-12 h-12 bg-indigo-100 rounded-full flex items-center justify-center mr-4">
                                <i class="fas fa-layer-group text-indigo-500 text-xl"></i>
                            </div>
                            <h4 class="text-lg font-semibold">Buffer</h4>
                        </div>
                        <p class="text-gray-600">包含数据且用于读写的线形表结构，包含capacity、limit、position等核心属性</p>
                    </div>
                    
                    <!-- Channels Card -->
                    <div class="bg-white p-6 rounded-lg shadow-md">
                        <div class="flex items-center mb-4">
                            <div class="w-12 h-12 bg-purple-100 rounded-full flex items-center justify-center mr-4">
                                <i class="fas fa-exchange-alt text-purple-500 text-xl"></i>
                            </div>
                            <h4 class="text-lg font-semibold">Channels</h4>
                        </div>
                        <p class="text-gray-600">双向交流的通道，包含SocketChannel、FileChannel和ServerSocketChannel三种</p>
                    </div>
                    
                    <!-- Selector Card -->
                    <div class="bg-white p-6 rounded-lg shadow-md">
                        <div class="flex items-center mb-4">
                            <div class="w-12 h-12 bg-blue-100 rounded-full flex items-center justify-center mr-4">
                                <i class="fas fa-sitemap text-blue-500 text-xl"></i>
                            </div>
                            <h4 class="text-lg font-semibold">Selector</h4>
                        </div>
                        <p class="text-gray-600">将多元异步I/O操作集中到一个或多个线程中，提高系统效率</p>
                    </div>
                </div>
            </div>
            
            <div class="mb-12">
                <h3 class="text-2xl font-semibold mb-6">3.1 实现文件拷贝</h3>
                <div class="code-block">
                    <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy mr-2"></i>复制</button>
                    <pre class="p-4 text-gray-200 overflow-x-auto"><code>public static void main(String[] args) throws Exception {
    String inFile = "C:\\Users\\DELL\\Pictures\\电商图片\\5ab47b2cN8ab58667.jpg";
    String outFile = "C:\\Users\\DELL\\Desktop\\xxxx.jpg";
    
    // 1.创建读写的FileChannel对象
    FileChannel inchannel = new FileInputStream(inFile).getChannel();
    FileChannel outCHannel = new FileOutputStream(outFile).getChannel();
    
    // 2.准备一个ByteBuffer
    ByteBuffer byteBuffer = ByteBuffer.allocate(1024);
    
    // 3.读取内容缓存区
    while(inchannel.read(byteBuffer) != -1){
        byteBuffer.flip(); // 将界限设置为位置的地方，将位置设置为0
        outCHannel.write(byteBuffer); // 把缓存区中的数据写入到输出的Channel中
        byteBuffer.clear(); // 清空缓存区
    }
    inchannel.close();
    outCHannel.close();
}</code></pre>
                </div>
            </div>
            
            <div class="mb-12">
                <h3 class="text-2xl font-semibold mb-6">3.2 通讯实现</h3>
                
                <div class="grid md:grid-cols-2 gap-8">
                    <!-- Server Code -->
                    <div>
                        <h4 class="text-xl font-medium mb-4 flex items-center">
                            <i class="fas fa-server text-purple-500 mr-2"></i> 服务端代码
                        </h4>
                        <div class="code-block">
                            <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy mr-2"></i>复制</button>
                            <pre class="p-4 text-gray-200 overflow-x-auto"><code>public static void main(String[] args) throws Exception {
    // 1.创建ServerSocketChannel
    ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
    
    // 2.绑定端口号
    serverSocketChannel.bind(new InetSocketAddress("localhost",8080));
    
    // 3.接收客户端连接
    SocketChannel socketChannel1 = serverSocketChannel.accept();
    
    if(serverSocketChannel != null){
        // 3.创建一个缓存区
        ByteBuffer byteBuffer = ByteBuffer.allocate(1024);
        
        // 4.把客户端的信息读取到缓存区中
        socketChannel1.read(byteBuffer);
        
        // 5.把缓存区转成字节数组
        byte[] bytes = byteBuffer.array();
        System.out.println("服务端读取的内容："+ new String(bytes,"utf-8"));
        
        // 6.服务端响应数据给客户端
        byteBuffer.put("_服务端添加的数据".getBytes("utf-8"));
        
        // 7.把缓存中转成可读的
        byteBuffer.flip();
        socketChannel1.write(byteBuffer);
        
        // 8.关闭channel
        socketChannel1.close();
    }
}</code></pre>
                        </div>
                    </div>
                    
                    <!-- Client Code -->
                    <div>
                        <h4 class="text-xl font-medium mb-4 flex items-center">
                            <i class="fas fa-laptop-code text-blue-500 mr-2"></i> 客户端代码
                        </h4>
                        <div class="code-block">
                            <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy mr-2"></i>复制</button>
                            <pre class="p-4 text-gray-200 overflow-x-auto"><code>public static void main(String[] args) throws Exception {
    // 1.创建SocketChannel
    SocketChannel socketChannel = SocketChannel.open();
    
    // 2.连接服务端,连接成功返回true
    if(socketChannel.connect(new InetSocketAddress("localhost",8080))){
        System.out.println("客户端连接成功");
        
        // 3.创建一个缓存区
        ByteBuffer byteBuffer = ByteBuffer.allocate(1024);
        
        // 4.把要发送给服务端的数据写在缓存区中
        byteBuffer.put("hello".getBytes("utf-8"));
        
        // 5.设置缓存区中只读
        byteBuffer.flip();
        
        // 6.把缓存区写入到chanel中
        socketChannel.write(byteBuffer);
        
        // 7.读取服务端响应过来的数据
        byteBuffer.clear(); // 清空之前的缓存区
        socketChannel.read(byteBuffer);
        System.out.println("客户端读取内容:"+new String(byteBuffer.array(),"utf-8"));
        
        // 8.关闭
        socketChannel.close();
    };
}</code></pre>
                        </div>
                    </div>
                </div>
            </div>
            
            <div>
                <h3 class="text-2xl font-semibold mb-6">3.3 多路复用器实现</h3>
                
                <div class="grid md:grid-cols-2 gap-8">
                    <!-- Server Code -->
                    <div>
                        <h4 class="text-xl font-medium mb-4 flex items-center">
                            <i class="fas fa-server text-purple-500 mr-2"></i> 服务端代码
                        </h4>
                        <div class="code-block">
                            <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy mr-2"></i>复制</button>
                            <pre class="p-4 text-gray-200 overflow-x-auto"><code>public static void main(String[] args) throws Exception {
    // 1.创建ServerSocketChannel
    ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
    
    // 这里必须是非阻塞模式
    serverSocketChannel.configureBlocking(false);
    // 2.绑定端口号
    serverSocketChannel.bind(new InetSocketAddress("localhost",8080));
    
    // 创建多路复用器
    Selector selector = Selector.open();
    
    // 把Selector绑定到ServerSoket上面
    serverSocketChannel.register(selector, SelectionKey.OP_ACCEPT);
    
    // select()是个阻塞方法，如果select()大于0，说明有客户端发送了请求过来
    while(selector.select()> 0){
        // 获取多路复用器中的所有事件
        Set&lt;SelectionKey&gt; selectionKeys = selector.selectedKeys();
        for (SelectionKey sk:new HashSet&lt;&gt;(selectionKeys)) {
            selectionKeys.remove(sk);
            if(sk.isAcceptable()){ // 判断当前事件是否连接类型
                ServerSocketChannel ssc = (ServerSocketChannel) sk.channel();
                
                // 获取新的连接对象
                SocketChannel newSc = ssc.accept();
                
                // 设置线程为非阻塞的模式
                newSc.configureBlocking(false);
                
                // 把新的连接注册到多路复用器上
                newSc.register(selector,SelectionKey.OP_READ);
            }else if(sk.isReadable()){ // 判断当前事件时是否是消息类型
                SocketChannel socketChannel = (SocketChannel) sk.channel();
                ByteBuffer byteBuffer = ByteBuffer.allocate(1024);
                socketChannel.read(byteBuffer); // 把客户端发送过来的内容读取到缓存区中
                System.out.println("服务端读取内容:"+new String(byteBuffer.array(),"utf-8"));
                
                byteBuffer.put("这是服务端响应数据".getBytes());
                byteBuffer.flip();
                socketChannel.write(byteBuffer);
            }
        }
    };
}</code></pre>
                        </div>
                    </div>
                    
                    <!-- Client Code -->
                    <div>
                        <h4 class="text-xl font-medium mb-4 flex items-center">
                            <i class="fas fa-laptop-code text-blue-500 mr-2"></i> 客户端代码
                        </h4>
                        <div class="code-block">
                            <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy mr-2"></i>复制</button>
                            <pre class="p-4 text-gray-200 overflow-x-auto"><code>public static void main(String[] args) throws Exception {
    // 1.创建SocketChannel
    SocketChannel socketChannel = SocketChannel.open();
    
    // 2.连接服务端,连接成功返回true
    if(socketChannel.connect(new InetSocketAddress("localhost",8080))){
        System.out.println("客户端连接成功");
        while(true){
            Scanner scanner = new Scanner(System.in);
            String next = scanner.next();
            // 3.创建一个缓存区
            ByteBuffer byteBuffer = ByteBuffer.allocate(1024);
            
            // 4.把要发送给服务端的数据写在缓存区中
            byteBuffer.put(next.getBytes("utf-8"));
            
            // 5.设置缓存区中只读
            byteBuffer.flip();
            
            // 6.把缓存区写入到chanel中
            socketChannel.write(byteBuffer);
            
            // 7.读取服务端响应过来的数据
            byteBuffer.clear(); // 清空之前的缓存区
            socketChannel.read(byteBuffer);
            System.out.println("客户端读取内容:"+new String(byteBuffer.array(),"utf-8"));
        }
    };
}</code></pre>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Comparison Section -->
        <section id="comparison" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-2 h-12 bg-indigo-500 mr-4"></div>
                <h2 class="text-3xl font-bold">4. IO与NIO区别</h2>
            </div>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
                <div class="p-6">
                    <div class="overflow-x-auto">
                        <table class="w-full comparison-table">
                            <thead>
                                <tr>
                                    <th class="text-left">IO</th>
                                    <th class="text-left">NIO</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>面向Stream</td>
                                    <td>面向Channel</td>
                                </tr>
                                <tr>
                                    <td>阻塞IO</td>
                                    <td>非阻塞IO</td>
                                </tr>
                                <tr>
                                    <td>无</td>
                                    <td>Selectors</td>
                                </tr>
                                <tr>
                                    <td>Byte</td>
                                    <td>ByteBuffer</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white p-6 rounded-lg shadow-md">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-random text-indigo-500 mr-2"></i> 通道和缓冲区
                    </h3>
                    <p class="text-gray-600">标准的IO基于字节流和字符流进行操作的，而NIO是基于通道（Channel）和缓冲区（Buffer）进行操作，数据总是从通道读取到缓冲区中，或者从缓冲区写入到通道中。</p>
                </div>
                
                <div class="bg-white p-6 rounded-lg shadow-md">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-bolt text-blue-500 mr-2"></i> 异步IO
                    </h3>
                    <p class="text-gray-600">Java NIO可以让你异步的使用IO，例如：当线程从通道读取数据到缓冲区时，线程还是可以进行其他事情。当数据被写入到缓冲区时，线程可以继续处理它。从缓冲区写入通道也类似。</p>
                </div>
                
                <div class="bg-white p-6 rounded-lg shadow-md md:col-span-2">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-network-wired text-purple-500 mr-2"></i> 多路复用器
                    </h3>
                    <p class="text-gray-600">Java NIO引入了多路复用的概念，选择器用于监听多个通道的事件（比如：连接打开，数据到达）。因此，单个的线程可以监听多个数据通道，大大提高了系统的可伸缩性和效率。</p>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12">
        <div class="container mx-auto max-w-6xl px-4 text-center">
            <div class="mb-6">
                <h3 class="text-xl font-bold text-white mb-2">技术小馆</h3>
                <a href="http://www.yuque.com/jtostring" class="text-indigo-400 hover:text-indigo-300 transition-colors">http://www.yuque.com/jtostring</a>
            </div>
            <div class="flex justify-center space-x-6">
                <a href="#" class="text-gray-400 hover:text-white transition-colors">
                    <i class="fab fa-github text-2xl"></i>
                </a>
                <a href="#" class="text-gray-400 hover:text-white transition-colors">
                    <i class="fab fa-twitter text-2xl"></i>
                </a>
                <a href="#" class="text-gray-400 hover:text-white transition-colors">
                    <i class="fab fa-linkedin text-2xl"></i>
                </a>
            </div>
        </div>
    </footer>

    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default'
        });
        
        function copyCode(button) {
            const codeBlock = button.nextElementSibling;
            const range = document.createRange();
            range.selectNode(codeBlock);
            window.getSelection().removeAllRanges();
            window.getSelection().addRange(range);
            document.execCommand('copy');
            window.getSelection().removeAllRanges();
            
            const originalText = button.innerHTML;
            button.innerHTML = '<i class="fas fa-check mr-2"></i>已复制';
            setTimeout(() => {
                button.innerHTML = originalText;
            }, 2000);
        }
        
        // Smooth scrolling for anchor links
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```